home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / bash-builtins < prev    next >
Encoding:
Text File  |  2010-11-16  |  3.1 KB  |  129 lines

  1. # bash alias completion
  2. #
  3. _alias()
  4. {
  5.     local cur
  6.  
  7.     COMPREPLY=()
  8.     _get_comp_words_by_ref cur
  9.  
  10.     case $COMP_LINE in
  11.         *[^=])
  12.             COMPREPLY=( $( compgen -A alias -- "$cur" ) )
  13.             ;;
  14.         *=)
  15.             COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | sed \
  16.                 -e 's|^alias '"$cur"'\(.*\)$|\1|' )" )
  17.             ;;
  18.     esac
  19. }
  20. complete -F _alias -o nospace alias
  21.  
  22. # bash export completion
  23. #
  24. _export()
  25. {
  26.     local cur
  27.  
  28.     COMPREPLY=()
  29.     _get_comp_words_by_ref cur
  30.  
  31.     case $COMP_LINE in
  32.         *=\$*)
  33.             COMPREPLY=( $( compgen -v -P '$' -- "${cur#*=\$}" ) )
  34.             ;;
  35.         *[^=])
  36.             COMPREPLY=( $( compgen -v -S '=' -- "$cur" ) )
  37.             ;;
  38.         *=)
  39.             COMPREPLY=( "$( eval echo -n \"$`echo ${cur%=}`\" |
  40.                 ( echo -n \'
  41.                   sed -e 's/'\''/'\''\\\'\'''\''/g'
  42.                   echo -n \' ) )" )
  43.             ;;
  44.     esac
  45. }
  46. complete -F _export -o default -o nospace export
  47.  
  48. # bash shell function completion
  49. #
  50. _function()
  51. {
  52.     local cur prev
  53.  
  54.     COMPREPLY=()
  55.     _get_comp_words_by_ref cur prev
  56.  
  57.     if [[ $1 == @(declare|typeset) ]]; then
  58.         if [ "$prev" = -f ]; then
  59.             COMPREPLY=( $( compgen -A function -- "$cur" ) )
  60.         elif [[ "$cur" == -* ]]; then
  61.             COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- "$cur" ) )
  62.         fi
  63.     elif [ $COMP_CWORD -eq 1 ]; then
  64.         COMPREPLY=( $( compgen -A function -- "$cur" ) )
  65.     else
  66.         COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" )
  67.     fi
  68. }
  69. complete -F _function function declare typeset
  70.  
  71. # bash complete completion
  72. #
  73. _complete()
  74. {
  75.     local cur prev
  76.  
  77.     COMPREPLY=()
  78.     _get_comp_words_by_ref cur prev
  79.  
  80.     case $prev in
  81.         -o)
  82.             COMPREPLY=( $( compgen -W 'bashdefault default dirnames filenames \
  83.                 nospace plusdirs' -- "$cur" ) )
  84.             return 0
  85.             ;;
  86.  
  87.         -A)
  88.             COMPREPLY=( $( compgen -W 'alias arrayvar binding \
  89.                 builtin command directory disabled enabled \
  90.                 export file function group helptopic hostname \
  91.                 job keyword running service setopt shopt \
  92.                 signal stopped user variable' -- "$cur" ) )
  93.             return 0
  94.             ;;
  95.  
  96.         -C)
  97.             COMPREPLY=( $( compgen -A command -- "$cur" ) )
  98.             return 0
  99.             ;;
  100.         -F)
  101.             COMPREPLY=( $( compgen -A function -- "$cur" ) )
  102.             return 0
  103.             ;;
  104.         -p|-r)
  105.             COMPREPLY=( $( complete -p | sed -e 's|.* ||' ) )
  106.             COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
  107.             return 0
  108.             ;;
  109.  
  110.     esac
  111.  
  112.     if [[ "$cur" == -* ]]; then
  113.         # relevant options completion
  114.         COMPREPLY=( $( compgen -W '-a -b -c -d -e -f -g -j -k -o -s -v -u -A \
  115.             -G -W -P -S -X -F -C' -- "$cur" ) )
  116.     else
  117.         COMPREPLY=( $( compgen -A command -- "$cur" ) )
  118.     fi
  119. }
  120. complete -F _complete complete
  121.  
  122. # Local variables:
  123. # mode: shell-script
  124. # sh-basic-offset: 4
  125. # sh-indent-comment: t
  126. # indent-tabs-mode: nil
  127. # End:
  128. # ex: ts=4 sw=4 et filetype=sh
  129.